package com.wooophone.mpyeah.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.wooophone.mpyeah.dao.BrandCommentReplyDao;
import com.wooophone.mpyeah.entity.BrandCommentReply;
import com.wooophone.mpyeah.mapper.BrandCommentReplyMapper;

public class BrandCommentReplyDaoImpl implements BrandCommentReplyDao {

	@Autowired
	private BrandCommentReplyMapper brandCommentReplyMapper;
	public void setBrandCommentReplyMapper(
			BrandCommentReplyMapper brandCommentReplyMapper) {
		this.brandCommentReplyMapper = brandCommentReplyMapper;
	}

	@Override
	public BrandCommentReply save(BrandCommentReply obj) {
		brandCommentReplyMapper.save(obj);
		return obj;
	}

	@Override
	public int update(BrandCommentReply obj) {
		return brandCommentReplyMapper.update(obj);
	}

	@Override
	public int delete(String id) {
		return brandCommentReplyMapper.delete(id);
	}

	@Override
	public BrandCommentReply get(String id) {
		return brandCommentReplyMapper.get(id);
	}

	@Override
	public List<BrandCommentReply> list() {
		return brandCommentReplyMapper.list();
	}

	@Override
	public List<BrandCommentReply> list(int offset, int limit) {
		Map<String, Object> parameter=new HashMap<String, Object>();
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		return brandCommentReplyMapper.list();
	}

	@Override
	public int count() {
		return brandCommentReplyMapper.count();
	}

	@Override
	public List<BrandCommentReply> find(Map<String, Object> parameter) {
		return brandCommentReplyMapper.listByParameter(parameter);
	}

	@Override
	public List<BrandCommentReply> find(Map<String, Object> parameter, int offset, int limit) {
		parameter.put("limit", limit);
		parameter.put("offset", offset);
		return brandCommentReplyMapper.listByParameter(parameter);
	}

	@Override
	public int count(Map<String, Object> parameter) {
		return brandCommentReplyMapper.countByParameter(parameter);
	}

	@Override
	public int count(String keyword) {
		keyword="%"+keyword+"%";
		Map<String, Object> parameter=new HashMap<String, Object>();
		parameter.put("keyword", keyword);
		return brandCommentReplyMapper.countByKeyword(parameter);
	}

	@Override
	public List<BrandCommentReply> search(String keyword, int offset, int limit) {
		Map<String, Object> parameter=new HashMap<String, Object>();
		parameter.put("limit", limit);
		parameter.put("offset", offset);
		parameter.put("keyword", "%"+keyword+"%");
		return brandCommentReplyMapper.search(parameter);
	}

	@Override
	public int deleteByCommentId(String commentId) {
		return	brandCommentReplyMapper.deleteByCommentId(commentId);
	}

}
